package com.mihu.stmall.manager.mapper;


import com.mihu.stmall.manager.entiy.GoodsPic;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsPicMapper {

    //批量插入图片
    @Insert({"<script>",
            "insert into goods_pic",
            "(url,goods_id)",
            "value",
            "<foreach collection='pics' item='pic' separator=','>",
            "(#{pic.url},#{pic.goodsId})",
            "</foreach>",
            "</script>"
    })
    int insert(@Param("pics") List<GoodsPic> pics);

    @Delete("delete from goods_pic where goods_id=#{goodsId}")

    int deleteByGoodsId(Integer goodsId);



    @Select("select * from goods_pic where goods_id=#{goodsId}")
    List<GoodsPic>  selectByGoodsId(Integer goodsId);


    int update(@Param("pics") List<GoodsPic> pics,@Param("goodsPic") List<GoodsPic> goodsPic);
}
